package com.qk.management.mapper;

import com.qk.entity.Activity;
import org.apache.ibatis.annotations.*;

import java.util.List;

/*
 *  @author SHCJ
 *  @created 2025/10/7 20:14
 *  @description
 */
@Mapper
public interface ActivityMapper {
    List<Activity> selectByPage(Integer channel, Integer type, Integer status);

    @Delete("delete from activity where id = #{id}")
    void delete(Integer id);

    @Insert("insert into activity(channel, name, start_time, end_time, description, type, discount, voucher, create_time, update_time) values(#{channel}, #{name}, #{startTime}, #{endTime}, #{description}, #{type}, #{discount}, #{voucher}, #{createTime}, #{updateTime})")
    void add(Activity activity);

    @Select("select * from activity where id = #{id}")
    Activity findById(Integer id);

    @Update("update activity set channel = #{channel}, name = #{name}, start_time = #{startTime}, end_time = #{endTime}, description = #{description}, type = #{type}, discount = #{discount}, voucher = #{voucher}, create_time = #{createTime}, update_time = #{updateTime} where id = #{id}")
    void update(Activity activity);

    @Select("select * from activity where channel = #{channel}")
    List<Activity> findByType(Integer channel);
}
